package cn.wolfcode.business.controller;

import cn.wolfcode.business.domain.BusStatementItem;
import cn.wolfcode.business.service.IBusStatementItemService;
import cn.wolfcode.business.vo.BusStatementItemVO;
import cn.wolfcode.common.core.controller.BaseController;
import cn.wolfcode.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 结算单明细Controller
 * 
 * @author wolfcode
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/business/item")
public class BusStatementItemController extends BaseController
{
    @Autowired
    private IBusStatementItemService busStatementItemService;

    /**
     * 查询结算单明细集合列表
     */
    @GetMapping
    public AjaxResult list(Long statementId){
        BusStatementItem item = new BusStatementItem();
        item.setStatementId(statementId);
        List<BusStatementItem> busStatementItems = busStatementItemService.selectBusStatementItemList(item);
        return AjaxResult.success(busStatementItems);
    }

    /**
     * 结算单明细保存
     * @return
     */
    @PostMapping
    public AjaxResult itemSave(@RequestBody BusStatementItemVO vo){
        return toAjax(busStatementItemService.itemSave(vo));
    }

    /**
     * 结算单支付功能
     */
    @PatchMapping(headers = "cmd=pay")
    public AjaxResult pay(@RequestBody BusStatementItemVO vo){
        return toAjax(busStatementItemService.pay(vo));
    }
}
